package com.utils;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import com.log.LogMonitorFactroy;

/**
 * Title: <br>
 * Description:  <br>
 * Copyright: WangGuangya<br>
 * Company: WangGuangya<br>
 * @author WangGuangya
 * @version 1.0
 * @date 2018-02-23
 */

public class WatchThread extends Thread {

	InputStream in; 
	boolean over; 
	public WatchThread(InputStream in) { 
		this.in = in; 
		over = false; 
	} 

	public void run() { 
		try { 
			if (in == null) {
				return; 
			}
			BufferedReader br = new BufferedReader(new InputStreamReader(in, "GBK")); 
			String string = "";
			while (!over) { 
				while((string = br.readLine())!= null) {
//					System.out.println(new String(string.getBytes("GBK"), "UTF-8"));
					LogMonitorFactroy.newInstance().append(string);
				}
			} 
		} catch (Exception e) { 
			e.printStackTrace(); 
		} 
	} 
	public void setOver(boolean over) { 
		this.over = over; 
	} 
}
